package com.example.administrator.dc.adapter;

import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.PopupWindow;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.example.administrator.dc.Activity.ClubDetail;
import com.example.administrator.dc.Activity.Detail;
import com.example.administrator.dc.Bean.Clublist;
import com.example.administrator.dc.Bean.UserPhoto;
import com.example.administrator.dc.R;
import com.example.administrator.dc.helper.RoundImageView;
import com.squareup.picasso.Picasso;
import com.squareup.picasso.Target;

import java.util.List;

/**
 * Created by Administrator on 2017/9/19.
 */

public class ClubListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
    private Context mContext;
    private List mDataList;
    private LayoutInflater mLayoutInflater;
    private PopupWindow mPop;
    private int result;
    private String userid;
    private String followid;


    public ClubListAdapter(Context mContext , List mDataList){
        this. mContext=mContext;
        this.mDataList=mDataList;
        //this.mLayoutInflater=LayoutInflater.from(mContext);
    }
    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View v = mLayoutInflater.from(parent.getContext()).inflate(R.layout.club, parent, false);
        return new ClubListAdapter.ViewHolder(v);
    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
        final Clublist entity = (Clublist) mDataList.get(position);
        if (null == entity)
            return;
        final ClubListAdapter.ViewHolder viewHolder = (ClubListAdapter.ViewHolder) holder;
        viewHolder.user_content.setText(entity.getClub_name());
        if (!"".equals(entity.getThumb())) {
            Picasso.with(mContext).load("http://172.24.10.175/workout/Uploads/" + entity.getThumb()).into( viewHolder.user_image);;
        }

        viewHolder.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                Intent intent=new Intent(mContext,ClubDetail.class);
                intent.putExtra("id",entity.getId());
                mContext.startActivity(intent);

            }
        });

    }

    @Override
    public int getItemCount() {
        return mDataList.size();
    }
    public class ViewHolder extends RecyclerView.ViewHolder{
        ImageView user_image;
      //  RelativeLayout background;
        TextView user_content;


        public ViewHolder(View itemView) {
            super(itemView);
            user_image=(ImageView) itemView.findViewById(R.id.userphoto_cardview_photo);
            user_content=(TextView) itemView.findViewById(R.id.userphoto_cardview_content);
           // background= (RelativeLayout) itemView.findViewById(R.id.Clubbackground);

        }
    }
}
